﻿using System.ServiceModel.Activation;
using Silverlight.Training.Server.Common.Contracts;
using Silverlight.Training.Server.Common.Feedbacks;
using Silverlight.Training.Server.Interfaces;
using Silverlight.Training.Server.Managers;

namespace Silverlight.Training.Server
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class EMService : IEMService
    {
        private ServiceManager manager;

        public EMService()
        {
            manager = new ServiceManager();
        }

        #region Employee

        /// <summary>
        /// This method aims to get all employees from database
        /// </summary>
        /// <returns>
        /// A list of employees
        /// </returns>
        public CollectionFeedback<Employee> GetEmployeeCollection()
        {
            return manager.GetEmployeeCollection();
        }

        /// <summary>
        /// This method aims to get detailed information of an employee based on its ID.
        /// </summary>
        /// <param name="employeeID">
        /// The ID of the desired employee
        /// </param>
        /// <returns>
        /// A object of Employee class with full information
        /// </returns>

        public SingleFeedback<Employee> GetSingleEmployee(int employeeID)
        {
            return manager.GetSingleEmployee(employeeID);
        }

        /// <summary>
        /// This method aims to insert a new object into database
        /// </summary>
        /// <param name="data">
        /// The Employee object to be inserted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about 
        ///    - inserting result and 
        ///    - the ID of new object if success or -1
        /// </returns>
        public SingleFeedback<int> InsertEmployee(Employee data)
        {
            return manager.Insert(data);
        }

        /// <summary>
        /// This method aims to update an existing record in database
        /// </summary>
        /// <param name="data">
        /// The Employee object to be updated
        /// </param>
        /// <returns>
        /// A Feedback object containing information about updating result
        /// </returns>
        public Feedback UpdateEmployee(Employee data)
        {
            return manager.Update(data);
        }

        /// <summary>
        /// This method aims to delete an existing record in database
        /// </summary>
        /// <param name="data">
        /// The Employee object to be deleted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about deleting result
        /// </returns>
        public Feedback DeleteEmployee(Employee data)
        {
            return manager.Delete(data);
        }

        #endregion

        #region Department

        /// <summary>
        /// This method aims to get all departments from database
        /// </summary>
        /// <returns>
        /// A list of departments
        /// </returns>
        public CollectionFeedback<Department> GetDepartmentCollection()
        {
            return manager.GetDepartmentCollection();
        }

        /// <summary>
        /// This method aims to get detailed information of an department based on its ID.
        /// </summary>
        /// <param name="deptID">
        /// The ID of the desired department
        /// </param>
        /// <returns>
        /// A object of Department class with full information
        /// </returns>
        public SingleFeedback<Department> GetSingleDepartment(int deptID)
        {
            return manager.GetSingleDepartment(deptID);
        }

        /// <summary>
        /// This method aims to insert a new object into database
        /// </summary>
        /// <param name="data">
        /// The Department object to be inserted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about 
        ///    - inserting result and 
        ///    - the ID of new object if success or -1
        /// </returns>
        public SingleFeedback<int> InsertDepartment(Department data)
        {
            return manager.Insert(data);
        }

        /// <summary>
        /// This method aims to update an existing record in database
        /// </summary>
        /// <param name="data">
        /// The Department object to be updated
        /// </param>
        /// <returns>
        /// A Feedback object containing information about updating result
        /// </returns>
        public Feedback UpdateDepartment(Department data)
        {
            return manager.Update(data);
        }

        /// <summary>
        /// This method aims to delete an existing record in database
        /// </summary>
        /// <param name="data">
        /// The Department object to be deleted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about deleting result
        /// </returns>
        public Feedback DeleteDepartment(Department data)
        {
            return manager.Delete(data);
        }

        #endregion

        #region JobTitle

        /// <summary>
        /// This method aims to get all job titles from database
        /// </summary>
        /// <returns>
        /// A list of job titles
        /// </returns>
        public CollectionFeedback<JobTitle> GetJobTitleCollection()
        {
            return manager.GetJobTitleCollection();
        }

        /// <summary>
        /// This method aims to get detailed information of an job title based on its ID.
        /// </summary>
        /// <param name="jTitleID">
        /// The ID of the desired job title
        /// </param>
        /// <returns>
        /// A object of JobTitle class with full information
        /// </returns>
        public SingleFeedback<JobTitle> GetSingleJobTitle(int jTitleID)
        {
            return manager.GetSingleJobTitle(jTitleID);
        }

        /// <summary>
        /// This method aims to insert a new object into database
        /// </summary>
        /// <param name="data">
        /// The JobTitle object to be inserted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about 
        ///    - inserting result and 
        ///    - the ID of new object if success or -1
        /// </returns>
        public SingleFeedback<int> InsertJobTitle(JobTitle data)
        {
            return manager.Insert(data);
        }

        /// <summary>
        /// This method aims to update an existing record in database
        /// </summary>
        /// <param name="data">
        /// The JobTitle object to be updated
        /// </param>
        /// <returns>
        /// A Feedback object containing information about updating result
        /// </returns>
        public Feedback UpdateJobTitle(JobTitle data)
        {
            return manager.Update(data);
        }

        /// <summary>
        /// This method aims to delete an existing record in database
        /// </summary>
        /// <param name="data">
        /// The JobTitle object to be deleted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about deleting result
        /// </returns>
        public Feedback DeleteJobTitle(JobTitle data)
        {
            return manager.Delete(data);
        }

        #endregion

        #region EmployeeType

        /// <summary>
        /// This method aims to get all employee types from database
        /// </summary>
        /// <returns>
        /// A list of employee types
        /// </returns>
        public CollectionFeedback<EmployeeType> GetEmployeeTypeCollection()
        {
            return manager.GetEmployeeTypeCollection();
        }

        /// <summary>
        /// This method aims to get detailed information of an employee type based on its ID.
        /// </summary>
        /// <param name="eTypeID">
        /// The ID of the desired employee type
        /// </param>
        /// <returns>
        /// A object of EmployeeType class with full information
        /// </returns>
        public SingleFeedback<EmployeeType> GetSingleEmployeeType(int eTypeID)
        {
            return manager.GetSingleEmployeeType(eTypeID);
        }

        /// <summary>
        /// This method aims to insert a new object into database
        /// </summary>
        /// <param name="data">
        /// The EmployeeType object to be inserted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about 
        ///    - inserting result and 
        ///    - the ID of new object if success or -1
        /// </returns>
        public SingleFeedback<int> InsertEmployeeType(EmployeeType data)
        {
            return manager.Insert(data);
        }

        /// <summary>
        /// This method aims to update an existing record in database
        /// </summary>
        /// <param name="data">
        /// The EmployeeType object to be updated
        /// </param>
        /// <returns>
        /// A Feedback object containing information about updating result
        /// </returns>
        public Feedback UpdateEmployeeType(EmployeeType data)
        {
            return manager.Update(data);
        }

        /// <summary>
        /// This method aims to delete an existing record in database
        /// </summary>
        /// <param name="data">
        /// The EmployeeType object to be deleted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about deleting result
        /// </returns>
        public Feedback DeleteEmployeeType(EmployeeType data)
        {
            return manager.Delete(data);
        }

        #endregion
    }
}
